home *** CD-ROM | disk | FTP | other *** search
- package netscape.applet;
-
- import java.awt.Button;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Frame;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Insets;
- import java.awt.TextArea;
- import java.awt.Window;
- import java.io.File;
- import java.io.IOException;
- import netscape.debug.Debugger;
-
- class ConsoleFrame extends Frame {
- Console console;
- TextArea text;
- Button reset;
- Button hide;
-
- ConsoleFrame(Console var1) {
- this.console = var1;
- ((Frame)this).setTitle("Java Console");
- GridBagLayout var2 = new GridBagLayout();
- ((Container)this).setLayout(var2);
- this.text = new TextArea(20, 60);
- this.text.setEditable(false);
- GridBagConstraints var3 = new GridBagConstraints();
- var3.fill = 1;
- var3.weightx = (double)1.0F;
- var3.weighty = (double)1.0F;
- var3.gridwidth = 0;
- var2.setConstraints(this.text, var3);
- ((Container)this).add(this.text);
- HorizontalRule var4 = new HorizontalRule();
- GridBagConstraints var5 = new GridBagConstraints();
- var5.fill = 2;
- var5.weightx = (double)1.0F;
- var5.insets = new Insets(1, 1, 0, 0);
- var5.gridwidth = 0;
- var2.setConstraints(var4, var5);
- ((Container)this).add(var4);
- this.reset = new Button("Clear");
- GridBagConstraints var6 = new GridBagConstraints();
- var6.insets = new Insets(4, 0, 2, 4);
- var6.anchor = 13;
- var2.setConstraints(this.reset, var6);
- ((Container)this).add(this.reset);
- this.hide = new Button("Close");
- GridBagConstraints var7 = new GridBagConstraints();
- var7.insets = new Insets(4, 0, 2, 4);
- var7.anchor = 13;
- var2.setConstraints(this.hide, var7);
- ((Container)this).add(this.hide);
- ((Window)this).pack();
- }
-
- public boolean handleEvent(Event var1) {
- if (var1.id != 201 && (var1.target != this.hide || var1.id != 1001)) {
- if (var1.target == this.reset && var1.id == 1001) {
- this.console.reset();
- return true;
- } else {
- return super.handleEvent(var1);
- }
- } else {
- this.console.hide();
- return true;
- }
- }
-
- String getFileFullPath(String var1) {
- try {
- File var2 = new File(".", var1);
- SecurityManager.enablePrivilege("UniversalFileRead");
- SecurityManager.enablePrivilege("UniversalPropertyRead");
- return var2.getCanonicalPath();
- } catch (IOException var3) {
- return var1;
- }
- }
-
- public boolean keyDown(Event var1, int var2) {
- if (var2 >= 48 && var2 <= 57) {
- MozillaAppletContext.debug = var2 - 48;
- System.err.println("# Applet debug level set to " + MozillaAppletContext.debug);
- return true;
- } else if (var2 != 98 && var2 != 66) {
- if (var2 != 100 && var2 != 68) {
- if (var2 != 119 && var2 != 87) {
- if (var2 != 103 && var2 != 71) {
- if (var2 != 102 && var2 != 70) {
- if (var2 != 109 && var2 != 77) {
- if (var2 == 120) {
- String var7 = this.getFileFullPath("memory.out");
- System.err.print("# Dumping memory to '" + var7 + "'...");
- Console.dumpMemory(false);
- System.err.println("done.");
- return true;
- } else if (var2 == 88) {
- String var6 = this.getFileFullPath("memory.out");
- System.err.print("# Dumping memory to '" + var6 + "'...");
- Console.dumpMemory(true);
- System.err.println("done.");
- return true;
- } else if (var2 != 115 && var2 != 83) {
- if (var2 != 116 && var2 != 84) {
- if (var2 != 107 && var2 != 75) {
- if (var2 != 99 && var2 != 67) {
- if (var2 != 113 && var2 != 81) {
- if (var2 != 104 && var2 != 72 && var2 != 63 && var2 != 32) {
- if (var2 != 119 && var2 != 87) {
- if (var2 != 108 && var2 != 76) {
- return super.keyDown(var1, var2);
- } else {
- boolean var5 = !AppletClassLoader.getCaptureClassFiles();
- AppletClassLoader.setCaptureClassFiles(var5);
- System.err.println("# Class file capture " + (var5 ? "enabled" : "disabled"));
- return true;
- }
- } else {
- System.err.print("# Dumping application heaps...");
- Console.dumpApplicationHeaps();
- System.err.println("done.");
- return true;
- }
- } else {
- this.printConsoleHelp();
- return true;
- }
- } else {
- this.console.hide();
- return true;
- }
- } else {
- this.reset();
- return true;
- }
- } else {
- System.err.print("# Checkpointing memory...");
- Console.checkpointMemory();
- System.err.println("done.");
- return true;
- }
- } else {
- String var4 = this.getFileFullPath("memory.out");
- System.err.print("# Dumping thread info to '" + var4 + "'...");
- Console.dumpNSPRInfo();
- System.err.println("done.");
- return true;
- }
- } else {
- String var3 = this.getFileFullPath("memory.out");
- System.err.print("# Dumping memory summary to '" + var3 + "'...");
- Console.dumpMemorySummary();
- System.err.println("done.");
- return true;
- }
- } else {
- this.printMemoryStats("Memory");
- return true;
- }
- } else {
- System.err.println("# Performing finalization...");
- System.runFinalization();
- this.printMemoryStats("Finalization complete: memory");
- return true;
- }
- } else {
- System.err.println("# Performing a garbage collection...");
- System.gc();
- this.printMemoryStats("GC complete: memory");
- return true;
- }
- } else {
- System.err.print("# Dumping application heaps...");
- Console.dumpApplicationHeaps();
- System.err.println("done.");
- return true;
- }
- } else {
- MozillaAppletContext.dumpState(System.err);
- return true;
- }
- } else {
- System.err.println("# Breaking into debugger.");
- Debugger.debugBreak();
- return true;
- }
- }
-
- void printMemoryStats(String var1) {
- Runtime var2 = Runtime.getRuntime();
- System.err.println("# " + var1 + ": " + var2.totalMemory() + " free: " + var2.freeMemory() + " (" + var2.freeMemory() * 100L / var2.totalMemory() + "%)");
- }
-
- void printConsoleHelp() {
- System.out.println("Netscape Java Console Commands:");
- System.out.println(" b: break into the debugger (Windows only)");
- System.out.println(" c: clear console window");
- System.out.println(" d: dump applet context state to console");
- System.out.println(" f: finalize objects on finalization queue");
- System.out.println(" g: garbage collect");
- System.out.println(" h: print this help message");
- System.out.println(" l: capture all classes loaded by an applet to a directory");
- System.out.println(" m: print current memory use to console");
- System.out.println(" q: hide console");
- System.out.println(" s: dump memory summary to \"memory.out\"");
- System.out.println(" t: dump thread info to \"memory.out\"");
- System.out.println(" x: dump memory to \"memory.out\"");
- System.out.println(" X: dump memory (detailed) to \"memory.out\"");
- System.out.println(" 0-9: set applet debug level to <n>");
- System.out.println();
- }
-
- void reset() {
- this.text.setText("");
- }
- }
-